package com.xique.park.service.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xique.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xique.park.mapper.ParkChargeRuleCommMapper;
import com.xique.park.bean.domain.ParkChargeRuleComm;
import com.xique.park.service.service.IParkChargeRuleCommService;

/**
 * 计费价格-commService业务层处理
 *
 * @author xique
 * @date 2021-12-09
 */
@Service
public class ParkChargeRuleCommServiceImpl implements IParkChargeRuleCommService {

    @Autowired
    private ParkChargeRuleCommMapper parkChargeRuleCommMapper;

    /**
     * 查询计费价格-comm
     *
     * @param id 计费价格-commID
     * @return 计费价格-comm
     */
    @Override
    public ParkChargeRuleComm selectParkChargeRuleCommById(Long id) {
        return parkChargeRuleCommMapper.selectById(id);
    }

    /**
     * 查询计费价格-comm列表
     *
     * @param parkChargeRuleComm 计费价格-comm
     * @return 计费价格-comm
     */
    @Override
    public List<ParkChargeRuleComm> selectParkChargeRuleCommList(ParkChargeRuleComm parkChargeRuleComm) {
        QueryWrapper<ParkChargeRuleComm> wrapper = new QueryWrapper<>();
        if (null != parkChargeRuleComm.getParkId()) {
            wrapper.eq("park_id", parkChargeRuleComm.getParkId());
        }
        wrapper.ge("template", 7);
        wrapper.orderByAsc("create_time");
        return parkChargeRuleCommMapper.selectList(wrapper);
    }

    /**
     * 新增计费价格-comm
     *
     * @param parkChargeRuleComm 计费价格-comm
     * @return 结果
     */
    @Override
    public int insertParkChargeRuleComm(ParkChargeRuleComm parkChargeRuleComm) {
        parkChargeRuleComm.setCreateTime(DateUtils.getNowDate());
        return parkChargeRuleCommMapper.insert(parkChargeRuleComm);
    }

    /**
     * 修改计费价格-comm
     *
     * @param parkChargeRuleComm 计费价格-comm
     * @return 结果
     */
    @Override
    public int updateParkChargeRuleComm(ParkChargeRuleComm parkChargeRuleComm) {
        parkChargeRuleComm.setUpdateTime(DateUtils.getNowDate());
        return parkChargeRuleCommMapper.updateById(parkChargeRuleComm);
    }

    /**
     * 批量删除计费价格-comm
     *
     * @param ids 需要删除的计费价格-commID
     * @return 结果
     */
    @Override
    public int deleteParkChargeRuleCommByIds(List<Long> ids) {
        return parkChargeRuleCommMapper.deleteBatchIds(ids);
    }

    /**
     * 删除计费价格-comm信息
     *
     * @param id 计费价格-commID
     * @return 结果
     */
    @Override
    public int deleteParkChargeRuleCommById(Long id) {
        return parkChargeRuleCommMapper.deleteById(id);
    }
}
